import Vue from 'vue'
import Router from 'vue-router'


Vue.use(Router);

export default new Router({
    mode: 'history', //HTML5 History 模式,不丑的URL,需要后端配置
    routes: [{
            path: '/',
            redirect: { name: 'home' },
            component: resolve => require(['@/components/Nav'], resolve),
            children: [{
                path: 'home', //相对路径，路径为/home
                name: 'home',
                component: resolve => require(['@/components/Home'], resolve)
                //alias: '/' 别名，'/home'与'/'是同一个页面了
            }, {
                path: 'home/:postid',
                name: 'postid',
                component: resolve => require(['@/components/Postid'], resolve)
            },{
                path: 'categories',
                name: 'categories',
                component: resolve => require(['@/components/Categories'], resolve)
            },{
                path: 'categories/:tag/:postid',
                name: 'tagPostid',
                component: resolve => require(['@/components/Postid'], resolve)
            },{
                path: 'aboutme',
                name: 'aboutme',
                component: resolve => require(['@/components/Aboutme'], resolve)
            },{
            path:'404',
            name: '404',
            component: resolve => require(['@/components/404'], resolve)
        }]
        },{
            path:'*',
            redirect: { name: '404' }
        }] //懒加载
})